import { verifyJwt } from '../utils/auth'

export default defineEventHandler((event) => {
  const token = getCookie(event, 'auth_token')
  if (!token) return
  const payload = verifyJwt(token)
  if (payload) {
    // @ts-expect-error add to context
    event.context.auth = { userId: payload.userId }
  }
})


